home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / WindowMaker / WPrefs.app / KeyboardSettings.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-24  |  5.1 KB  |  186 lines

  1. /* KeyboardSettings.c- keyboard options (equivalent to xset)
  2.  * 
  3.  *  WPrefs - Window Maker Preferences Program
  4.  * 
  5.  *  Copyright (c) 1998 Alfredo K. Kojima
  6.  * 
  7.  *  This program is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2 of the License, or
  10.  *  (at your option) any later version.
  11.  *
  12.  *  This program is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with this program; if not, write to the Free Software
  19.  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 
  20.  *  USA.
  21.  */
  22.  
  23.  
  24. #include "WPrefs.h"
  25.  
  26. typedef struct _Panel {
  27.     WMFrame *frame;
  28.  
  29.     char *sectionName;
  30.  
  31.     char *description;
  32.  
  33.     CallbackRec callbacks;
  34.  
  35.     WMWindow *win;
  36.  
  37.     WMFrame *delaF;
  38.     WMButton *delaB[4];
  39.     WMLabel *dmsL;
  40.     WMTextField *dmsT;
  41.     
  42.     WMFrame *rateF;
  43.     WMButton *rateB[4];
  44.     WMLabel *rmsL;
  45.     WMTextField *rmsT;
  46.     
  47.     WMTextField *testT;
  48. } _Panel;
  49.  
  50.  
  51. #define ICON_FILE    "keyboard"
  52.  
  53.  
  54. static void
  55. createPanel(Panel *p)
  56. {
  57.     _Panel *panel = (_Panel*)p;
  58.     WMScreen *scr = WMWidgetScreen(panel->win);
  59.     int i;
  60.     WMColor *color;
  61.     WMFont *font;
  62.  
  63.     color = WMDarkGrayColor(scr);
  64.     font = WMSystemFontOfSize(scr, 10);
  65.     
  66.     panel->frame = WMCreateFrame(panel->win);
  67.     WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
  68.     WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
  69.     
  70.     /**************** Initial Key Repeat ***************/
  71.     panel->delaF = WMCreateFrame(panel->frame);
  72.     WMResizeWidget(panel->delaF, 495, 60);
  73.     WMMoveWidget(panel->delaF, 15, 10);
  74.     WMSetFrameTitle(panel->delaF, _("Initial Key Repeat"));
  75.         
  76.     for (i = 0; i < 4; i++) {
  77.     panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff);
  78.     WMResizeWidget(panel->delaB[i], 60, 20);
  79.     WMMoveWidget(panel->delaB[i], 70+i*60, 25);
  80.     if (i>0)
  81.         WMGroupButtons(panel->delaB[0], panel->delaB[i]);
  82.     switch (i) {
  83.      case 0:
  84.         WMSetButtonText(panel->delaB[i], "....a");
  85.         break;
  86.      case 1:
  87.         WMSetButtonText(panel->delaB[i], "...a");
  88.         break;
  89.      case 2:
  90.         WMSetButtonText(panel->delaB[i], "..a");
  91.         break;
  92.      case 3:
  93.         WMSetButtonText(panel->delaB[i], ".a");
  94.         break;
  95.     }
  96.     }
  97.     panel->dmsT = WMCreateTextField(panel->delaF);
  98.     WMResizeWidget(panel->dmsT, 50, 20);
  99.     WMMoveWidget(panel->dmsT, 345, 25);
  100. /*    WMSetTextFieldAlignment(panel->dmsT, WARight);*/
  101.  
  102.     panel->dmsL = WMCreateLabel(panel->delaF);
  103.     WMResizeWidget(panel->dmsL, 30, 16);
  104.     WMMoveWidget(panel->dmsL, 400, 30);
  105.     WMSetLabelTextColor(panel->dmsL, color);
  106.     WMSetLabelFont(panel->dmsL, font);
  107.     WMSetLabelText(panel->dmsL, "msec");
  108.     
  109.     WMMapSubwidgets(panel->delaF);
  110.     
  111.     /**************** Key Repeat Rate ***************/
  112.     panel->rateF = WMCreateFrame(panel->frame);
  113.     WMResizeWidget(panel->rateF, 495, 60);
  114.     WMMoveWidget(panel->rateF, 15, 95);
  115.     WMSetFrameTitle(panel->rateF, _("Key Repeat Rate"));
  116.     
  117.     for (i = 0; i < 4; i++) {
  118.     panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff);
  119.     WMResizeWidget(panel->rateB[i], 60, 20);
  120.     WMMoveWidget(panel->rateB[i], 70+i*60, 25);
  121.     if (i>0)
  122.         WMGroupButtons(panel->rateB[0], panel->rateB[i]);
  123.     switch (i) {
  124.      case 0:
  125.         WMSetButtonText(panel->rateB[i], "a....a");
  126.         break;
  127.      case 1:
  128.         WMSetButtonText(panel->rateB[i], "a...a");
  129.         break;
  130.      case 2:
  131.         WMSetButtonText(panel->rateB[i], "a..a");
  132.         break;
  133.      case 3:
  134.         WMSetButtonText(panel->rateB[i], "a.a");
  135.         break;
  136.     }
  137.     }
  138.     panel->rmsT = WMCreateTextField(panel->rateF);
  139.     WMResizeWidget(panel->rmsT, 50, 20);
  140.     WMMoveWidget(panel->rmsT, 345, 25);
  141. /*    WMSetTextFieldAlignment(panel->rmsT, WARight);*/
  142.     
  143.     panel->rmsL = WMCreateLabel(panel->rateF);
  144.     WMResizeWidget(panel->rmsL, 30, 16);
  145.     WMMoveWidget(panel->rmsL, 400, 30);
  146.     WMSetLabelTextColor(panel->rmsL, color);
  147.     WMSetLabelFont(panel->rmsL, font);
  148.     WMSetLabelText(panel->rmsL, "msec");
  149.     
  150.     WMMapSubwidgets(panel->rateF);
  151.  
  152.     panel->testT = WMCreateTextField(panel->frame);
  153.     WMResizeWidget(panel->testT, 480, 20);
  154.     WMMoveWidget(panel->testT, 20, 180);
  155.     WMSetTextFieldText(panel->testT, _("Type here to test"));
  156.  
  157.     WMReleaseColor(color);
  158.     WMReleaseFont(font);
  159.     
  160.     WMRealizeWidget(panel->frame);
  161.     WMMapSubwidgets(panel->frame);
  162. }
  163.  
  164.  
  165.  
  166. Panel*
  167. InitKeyboardSettings(WMScreen *scr, WMWindow *win)
  168. {
  169.     _Panel *panel;
  170.  
  171.     panel = wmalloc(sizeof(_Panel));
  172.     memset(panel, 0, sizeof(_Panel));
  173.  
  174.     panel->sectionName = _("Keyboard Preferences");
  175.  
  176.     panel->description = _("Not done");
  177.  
  178.     panel->win = win;
  179.     
  180.     panel->callbacks.createWidgets = createPanel;
  181.         
  182.     AddSection(panel, ICON_FILE);
  183.  
  184.     return panel;
  185. }
  186.